import http from '@/utils/request';

/**
 * 提交报名申请
 * @param {Object} enrollmentData 报名数据
 * @returns {Promise}
 */
export const submitEnrollment = (enrollmentData) => {
  return http.post('/enrollment', enrollmentData);
};

/**
 * 获取报名信息
 * @param {Number} id 报名ID
 * @returns {Promise}
 */
export const getEnrollment = (id) => {
  return http.get(`/enrollment/${id}`);
};

/**
 * 获取我的报名列表
 * @returns {Promise}
 */
export const getMyEnrollments = () => {
  return http.get('/enrollment/my');
};

/**
 * 取消报名
 * @param {Number} id 报名ID
 * @returns {Promise}
 */
export const cancelEnrollment = (id) => {
  return http.put(`/enrollment/${id}/cancel`);
};

/**
 * 上传报名材料
 * @param {Number} enrollmentId 报名ID
 * @param {String} materialType 材料类型
 * @param {String} filePath 文件路径
 * @returns {Promise}
 */
export const uploadMaterial = (enrollmentId, materialType, filePath) => {
  return http.upload('/enrollment/material', filePath, 'file', {
    enrollment_id: enrollmentId,
    material_type: materialType
  });
};

/**
 * 获取报名材料列表
 * @param {Number} enrollmentId 报名ID
 * @returns {Promise}
 */
export const getMaterials = (enrollmentId) => {
  return http.get(`/enrollment/${enrollmentId}/materials`);
};

/**
 * 选择教练
 * @param {Number} enrollmentId 报名ID
 * @param {Number} coachId 教练ID
 * @returns {Promise}
 */
export const selectCoach = (enrollmentId, coachId) => {
  return http.put(`/enrollment/${enrollmentId}/coach`, { coach_id: coachId });
};

/**
 * 生成报名表
 * @param {Number} enrollmentId 报名ID
 * @returns {Promise}
 */
export const generateEnrollmentForm = (enrollmentId) => {
  return http.get(`/enrollment/${enrollmentId}/form`);
};

/**
 * 生成体检表
 * @param {Number} enrollmentId 报名ID
 * @returns {Promise}
 */
export const generateMedicalForm = (enrollmentId) => {
  return http.get(`/enrollment/${enrollmentId}/medical-form`);
};